/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DA;

import BE.BEInterface;
import java.sql.*;
import java.util.ArrayList;
import javax.swing.JOptionPane;

/**
 *
 * @author hunter2409
 */
public class DAInterface {

    public ArrayList<BEInterface> obtenerInterfaces() {
        
        DAConexion bd = new DAConexion();
        Connection con = null;
        Statement s = null;
        ResultSet rs = null;
        String query = "SELECT idinterface, nombre, tipo FROM interface";
        ArrayList<BEInterface> lstInterface = new ArrayList<BEInterface>();
        
        try
        {
            //guardo los datos del perfil

            con = bd.conectar();
            //JOptionPane.showMessageDialog(null,"Hola mundo","Error",JOptionPane.ERROR_MESSAGE);
            
            s = con.createStatement();
            rs=s.executeQuery(query);
            
            while (rs.next())
            {
                BEInterface auxInterface= new BEInterface();
                auxInterface.setIdInterface(rs.getInt("idinterface"));
                auxInterface.setNombre(rs.getString("nombre"));
                auxInterface.setTipo(rs.getString("tipo"));
                
                lstInterface.add(auxInterface);
                
            }

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,"Problema al consultar la base de datos"+e.toString(),"Error",JOptionPane.ERROR_MESSAGE);
            bd.cierraConexion(con);
            return null;
            
        }
        bd.cierraConexion(con);
        
        return lstInterface;
        
        
    }
    
    
    
}
